package leetcode.code2024;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int maxConsecutiveAnswers(String answerKey, int k) {
		int l = 0, r = 0;
		int len = answerKey.length();
		char[] cs = answerKey.toCharArray();
		int t = 0, f = 0;
		int ans = 0;
		while (r < len) {
			char R = cs[r];
			if (R == 'T') {
				t++;
			} else {
				f++;
			}
			if (t > k && f > k) {
				ans = Math.max(ans, r - l) - 1;
				while (t > k && f > k) {
					char L = cs[l];
					if (L == 'T') {
						t--;
					} else {
						f--;
					}
					l++;
				}
			}
			r++;
		}
		ans = Math.max(ans, len - l);
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
